﻿
namespace System.Xml.Serialization.TestProject
{
    class TestSuite_NoInheritance
    {
        internal static void TestClass_Person()
        {
            string xml;
            string className = typeof(Person).Name;

            xml = "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">";
            TestHelper.TestRead<Person, IPersonRoot>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<Person, IPersonRoot>((person) => person.Name = "John Doe", xml);

            xml = "<Body>\r\n  <Name>John Doe</Name>\r\n</Body>";
            TestHelper.TestRead<Person, IPersonCustomRoot>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<Person, IPersonCustomRoot>((person) => person.Name = "John Doe", xml);

            xml = "<" + className + " Name=\"John Doe\" />";
            TestHelper.TestRead<Person, IPersonAttribute>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<Person, IPersonAttribute>((person) => person.Name = "John Doe", xml);

            xml = "<" + className + " Id=\"John Doe\" />";
            TestHelper.TestRead<Person, IPersonCustomAttribute>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<Person, IPersonCustomAttribute>((person) => person.Name = "John Doe", xml);

            xml = "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">";
            TestHelper.TestRead<Person, IPersonElement>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<Person, IPersonElement>((person) => person.Name = "John Doe", xml);

            xml = "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">";
            TestHelper.TestRead<Person, IPersonCustomElement>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<Person, IPersonCustomElement>((person) => person.Name = "John Doe", xml);

            xml = "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">";
            TestHelper.TestRead<Person, IPersonCustomElementString>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<Person, IPersonCustomElementString>((person) => person.Name = "John Doe", xml);
        }

        internal static void TestClass_IPersonClass()
        {
            string xml;
            string className = typeof(PersonClass).Name;

            xml = "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">";
            TestHelper.TestRead<PersonClass, IPersonRoot>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonClass, IPersonRoot>((person) => person.Name = "John Doe", xml);

            xml = "<Body>\r\n  <Name>John Doe</Name>\r\n</Body>";
            TestHelper.TestRead<PersonClass, IPersonCustomRoot>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonClass, IPersonCustomRoot>((person) => person.Name = "John Doe", xml);

            xml = "<" + className + " Name=\"John Doe\" />";
            TestHelper.TestRead<PersonClass, IPersonAttribute>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonClass, IPersonAttribute>((person) => person.Name = "John Doe", xml);

            xml = "<" + className + " Id=\"John Doe\" />";
            TestHelper.TestRead<PersonClass, IPersonCustomAttribute>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonClass, IPersonCustomAttribute>((person) => person.Name = "John Doe", xml);

            xml = "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">";
            TestHelper.TestRead<PersonClass, IPersonElement>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonClass, IPersonElement>((person) => person.Name = "John Doe", xml);

            xml = "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">";
            TestHelper.TestRead<PersonClass, IPersonCustomElement>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonClass, IPersonCustomElement>((person) => person.Name = "John Doe", xml);

            xml = "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">";
            TestHelper.TestRead<PersonClass, IPersonCustomElementString>(xml, (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonClass, IPersonCustomElementString>((person) => person.Name = "John Doe", xml);
        }

        internal static void TestClass_IPersonCustomClass()
        {
            string className = typeof(PersonCustomClass).Name;

            TestHelper.TestRead<PersonCustomClass, IPersonRoot>("<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomClass, IPersonRoot>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">");

            TestHelper.TestRead<PersonCustomClass, IPersonCustomRoot>("<Body>\r\n  <Name>John Doe</Name>\r\n</Body>", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomClass, IPersonCustomRoot>((person) => person.Name = "John Doe", "<Body>\r\n  <Name>John Doe</Name>\r\n</Body>");

            TestHelper.TestRead<PersonCustomClass, IPersonAttribute>("<" + className + " Name=\"John Doe\" />", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomClass, IPersonAttribute>((person) => person.Name = "John Doe", "<" + className + " Name=\"John Doe\" />");

            TestHelper.TestRead<PersonCustomClass, IPersonCustomAttribute>("<" + className + " Id=\"John Doe\" />", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomClass, IPersonCustomAttribute>((person) => person.Name = "John Doe", "<" + className + " Id=\"John Doe\" />");

            TestHelper.TestRead<PersonCustomClass, IPersonElement>("<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomClass, IPersonElement>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">");

            TestHelper.TestRead<PersonCustomClass, IPersonCustomElement>("<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomClass, IPersonCustomElement>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">");

            TestHelper.TestRead<PersonCustomClass, IPersonCustomElementString>("<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomClass, IPersonCustomElementString>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">");
        }

        internal static void TestClass_IPersonAttributeClass()
        {
            string className = typeof(PersonAttributeClass).Name;

            TestHelper.TestRead<PersonAttributeClass, IPersonRoot>("<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonAttributeClass, IPersonRoot>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">");

            TestHelper.TestRead<PersonAttributeClass, IPersonCustomRoot>("<Body>\r\n  <Name>John Doe</Name>\r\n</Body>", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonAttributeClass, IPersonCustomRoot>((person) => person.Name = "John Doe", "<Body>\r\n  <Name>John Doe</Name>\r\n</Body>");

            TestHelper.TestRead<PersonAttributeClass, IPersonAttribute>("<" + className + " Name=\"John Doe\" />", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonAttributeClass, IPersonAttribute>((person) => person.Name = "John Doe", "<" + className + " Name=\"John Doe\" />");

            TestHelper.TestRead<PersonAttributeClass, IPersonCustomAttribute>("<" + className + " Id=\"John Doe\" />", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonAttributeClass, IPersonCustomAttribute>((person) => person.Name = "John Doe", "<" + className + " Id=\"John Doe\" />");

            TestHelper.TestRead<PersonAttributeClass, IPersonElement>("<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonAttributeClass, IPersonElement>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">");

            TestHelper.TestRead<PersonAttributeClass, IPersonCustomElement>("<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonAttributeClass, IPersonCustomElement>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">");

            TestHelper.TestRead<PersonAttributeClass, IPersonCustomElementString>("<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonAttributeClass, IPersonCustomElementString>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">");
        }

        internal static void TestClass_IPersonCustomAttributeClass()
        {
            string className = typeof(PersonCustomAttributeClass).Name;

            TestHelper.TestRead<PersonCustomAttributeClass, IPersonRoot>("<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomAttributeClass, IPersonRoot>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">");

            TestHelper.TestRead<PersonCustomAttributeClass, IPersonCustomRoot>("<Body>\r\n  <Name>John Doe</Name>\r\n</Body>", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomAttributeClass, IPersonCustomRoot>((person) => person.Name = "John Doe", "<Body>\r\n  <Name>John Doe</Name>\r\n</Body>");

            TestHelper.TestRead<PersonCustomAttributeClass, IPersonAttribute>("<" + className + " Name=\"John Doe\" />", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomAttributeClass, IPersonAttribute>((person) => person.Name = "John Doe", "<" + className + " Name=\"John Doe\" />");

            TestHelper.TestRead<PersonCustomAttributeClass, IPersonCustomAttribute>("<" + className + " Id=\"John Doe\" />", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomAttributeClass, IPersonCustomAttribute>((person) => person.Name = "John Doe", "<" + className + " Id=\"John Doe\" />");

            TestHelper.TestRead<PersonCustomAttributeClass, IPersonElement>("<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomAttributeClass, IPersonElement>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">");

            TestHelper.TestRead<PersonCustomAttributeClass, IPersonCustomElement>("<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomAttributeClass, IPersonCustomElement>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">");

            TestHelper.TestRead<PersonCustomAttributeClass, IPersonCustomElementString>("<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomAttributeClass, IPersonCustomElementString>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">");
        }

        internal static void TestClass_IPersonElementClass()
        {
            string className = typeof(PersonElementClass).Name;

            TestHelper.TestRead<PersonElementClass, IPersonRoot>("<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonElementClass, IPersonRoot>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">");

            TestHelper.TestRead<PersonElementClass, IPersonCustomRoot>("<Body>\r\n  <Name>John Doe</Name>\r\n</Body>", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonElementClass, IPersonCustomRoot>((person) => person.Name = "John Doe", "<Body>\r\n  <Name>John Doe</Name>\r\n</Body>");

            TestHelper.TestRead<PersonElementClass, IPersonAttribute>("<" + className + " Name=\"John Doe\" />", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonElementClass, IPersonAttribute>((person) => person.Name = "John Doe", "<" + className + " Name=\"John Doe\" />");

            TestHelper.TestRead<PersonElementClass, IPersonCustomAttribute>("<" + className + " Id=\"John Doe\" />", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonElementClass, IPersonCustomAttribute>((person) => person.Name = "John Doe", "<" + className + " Id=\"John Doe\" />");

            TestHelper.TestRead<PersonElementClass, IPersonElement>("<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonElementClass, IPersonElement>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">");

            TestHelper.TestRead<PersonElementClass, IPersonCustomElement>("<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonElementClass, IPersonCustomElement>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">");

            TestHelper.TestRead<PersonElementClass, IPersonCustomElementString>("<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonElementClass, IPersonCustomElementString>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">");
        }

        internal static void TestClass_IPersonCustomElementClass()
        {
            string className = typeof(PersonCustomElementClass).Name;

            TestHelper.TestRead<PersonCustomElementClass, IPersonRoot>("<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomElementClass, IPersonRoot>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">");

            TestHelper.TestRead<PersonCustomElementClass, IPersonCustomRoot>("<Body>\r\n  <Name>John Doe</Name>\r\n</Body>", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomElementClass, IPersonCustomRoot>((person) => person.Name = "John Doe", "<Body>\r\n  <Name>John Doe</Name>\r\n</Body>");

            TestHelper.TestRead<PersonCustomElementClass, IPersonAttribute>("<" + className + " Name=\"John Doe\" />", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomElementClass, IPersonAttribute>((person) => person.Name = "John Doe", "<" + className + " Name=\"John Doe\" />");

            TestHelper.TestRead<PersonCustomElementClass, IPersonCustomAttribute>("<" + className + " Id=\"John Doe\" />", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomElementClass, IPersonCustomAttribute>((person) => person.Name = "John Doe", "<" + className + " Id=\"John Doe\" />");

            TestHelper.TestRead<PersonCustomElementClass, IPersonElement>("<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomElementClass, IPersonElement>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Name>John Doe</Name>\r\n</" + className + ">");

            TestHelper.TestRead<PersonCustomElementClass, IPersonCustomElement>("<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomElementClass, IPersonCustomElement>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">");

            TestHelper.TestRead<PersonCustomElementClass, IPersonCustomElementString>("<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">", (person) => person.Name == "John Doe");
            TestHelper.TestWrite<PersonCustomElementClass, IPersonCustomElementString>((person) => person.Name = "John Doe", "<" + className + ">\r\n  <Head>John Doe</Head>\r\n</" + className + ">");
        }
    }
}
